/*
 * @Author: wangwang 2723008256@qq.com
 * @Date: 2022-08-08 18:19:40
 * @LastEditors: wangwang 2723008256@qq.com
 * @LastEditTime: 2022-08-08 18:19:52
 * @FilePath: \jzjypc4.0\src\utils\resetMessage.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
//resetMessage.js
/**重置message，防止重复点击重复弹出message消息提示 */
import {
    Message
} from 'element-ui';

let messageInstance = null;

const resetMessage = (options) => {
        if(messageInstance) {
            messageInstance.close();

        }
        Message.closeAll(); //手动关闭所有消息提示实例
        messageInstance = Message(options);
        // console.log(Message(options));

};

['error','success','info','warning'].forEach(type => {
    resetMessage[type] = options => {
        if(typeof options === 'string') {
            options = {
                message:options
            }
        }
        options.type = type
        return resetMessage(options)
    }
})

export const message = resetMessage